package engineering;

public class StringCounter implements Comparable<StringCounter>{
  String str;
  int anz;

  public StringCounter(String s){
    str=s;
    anz=1;
  }

  public int addCount(int n){
    anz+=n;
    return anz;
  }

  public int getCount(){
    return anz;
  }

  public String getString(){
    return str;
  }

  public String toString(){
    return anz+"*"+str;
  }

  public int compareTo(StringCounter other){
    if(anz==other.anz) return str.compareTo(other.str);
    return anz>other.anz?1:-1;
  }

  public boolean equals(Object other){
    if(!(other instanceof StringCounter)) return false;
    return anz==((StringCounter)other).anz;
  }
}
